<?php

use App\Models\Region;
use App\Models\Spot;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
Route::post('/upload',function (Request $request){
    $path = Storage::disk('public')->putFile('editor-images', $request->file('img'));
    return response()->json(['errno'=>0,'data'=>[asset('storage/'.$path)]]);
});
Route::any('spot',function (Request $request){
    $q=$request->get('q');
    $region=Region::where('text',$q)->first();
    $spots=Spot::where('area',$region->id)->pluck('scene','scene');
    return response()->json($spots);
});
//指南
Route::group([
    'prefix' => 'guide',
], function () {
    Route::get('/', 'GuideController@index');
});
//指南
Route::group([
    'prefix' => 'rule',
], function () {
    Route::get('/', 'RuleController@index');
});
//用户地址
Route::group([
    'prefix' => 'address',
], function () {
    Route::post('/add', 'AddressController@add');
    Route::post('/list', 'AddressController@list');
    Route::post('/default/{id}', 'AddressController@default');
    Route::get('/{id}', 'AddressController@detail');
    Route::post('/delete/{id}', 'AddressController@delete');
});
//问卷调查
Route::group([
    'prefix' => 'questionnaire',
], function () {
    Route::post('/index', 'QuestionnaireController@index');
    Route::post('/questions', 'QuestionnaireController@questions');
    Route::post('/answer', 'QuestionnaireController@answer');
});
//积分
Route::group([
    'prefix' => 'integral',
], function () {
    Route::post('/exchange', 'ScoreController@exchange');      //积分兑换
    Route::post('/pexchange', 'ScoreController@prizeExchange');      //奖品兑换
    Route::get('/sign','ScoreController@sign');
    Route::post('/score','ScoreController@getScore');          //领取游记积分
    Route::post('/shop','ScoreController@scoreShop');          //用户已兑换奖品列表
    Route::get('/scorelist','ScoreController@scoreList');          //用户已兑换奖品列表
    Route::get('/prizeShop', 'ScoreController@prizeShop');      //福利抽奖奖品列表
    Route::get('/prizelist','ScoreController@prizeList');
    Route::post('/prize', 'ScoreController@prize');      //福利抽奖
    Route::get('/days', 'ScoreController@getSignDays');
});

//登录
Route::group([
    'prefix' => 'user',
], function () {
    Route::post('/login', 'UserController@login');       //登录
    Route::post('/checkToken', 'UserController@checkToken');
    Route::get('/album', 'UserController@album');       //我的相册
    Route::get('/love', 'UserController@love');       //我的收藏
    Route::get('/note', 'UserController@note');       //我的游记
    Route::get('/comment', 'UserController@comment');       //我的评论
    Route::get('/complaint', 'UserController@complaint');       //我的投诉
});
//七牛文件上传token
Route::group([
    'prefix' => 'uptoken',
], function () {
    Route::get('/', 'UploadController@index');       //获取七牛文件上传token
});
//评论
Route::group([
    'prefix' => 'comment',
], function () {
    Route::get('/{model}/{id}/{num?}', 'CommentController@index');    //获取评论列表
    Route::post('/store', 'CommentController@store');           //发表评论
    Route::post('/zan', 'CommentController@zan');   //点赞
    Route::post('/unzan', 'CommentController@unzan');     //取消点赞
});

//浏览用户
Route::group([
    'prefix' => 'browser',
], function () {
    Route::get('/{model}/{id}', 'BrowserController@index');    //获取浏览者列表
    Route::Post('/store', 'BrowserController@store');    //获取浏览者列表
});

//收藏
Route::group([
    'prefix' => 'love',
], function () {
    Route::get('/{model}/{id}', 'LoveController@index');    //是否收藏
    Route::post('/store', 'LoveController@love');      //收藏
    Route::post('/delete', 'LoveController@unlove');      //取消收藏
});

//投诉
Route::group([
    'prefix' => 'complaint',
], function () {
    Route::get('/menu', 'ComplaintController@menu');      //提交投诉
    Route::post('/store', 'ComplaintController@store');      //提交投诉
});
//banner
Route::group([
    'prefix' => 'banner',
], function () {
    Route::get('/index', 'BannerController@index');      //
    Route::get('/home', 'BannerController@home');      //
});

//景区汇总
Route::group([
    'prefix' => 'region',
], function () {
    Route::get('/index', 'RegionController@index');  //获取区域列表
    Route::get('/menu', 'RegionController@menu');  //获取景点列表
});


//                                           手绘地图

//基本信息
Route::group([
    'prefix' => 'mapinfo',
], function () {
    Route::get('/', 'MapinfoController@index');    //获取美食列表
});
//美食
Route::group([
    'prefix' => 'food',
], function () {
    Route::get('/index/{order?}', 'FoodController@index');    //获取美食列表
    Route::get('/menu', 'FoodController@menu');    //获取美食列表
    Route::get('/{id}', 'FoodController@show');      //获取美食详情
});

//景点
Route::group([
    'prefix' => 'scene',
], function () {
    Route::get('/index/{order?}/{num?}', 'SceneController@index');    //获取景点列表
    Route::get('/{id}', 'SceneController@show');      //获取景点详情
    Route::get('/search/{input}', 'SceneController@search');      //获取景点详情
    Route::get('/{id}/food', 'SceneController@getFoods');      //获取景点下的美食
});

//厕所
Route::group([
    'prefix' => 'washroom',
], function () {
    Route::get('/index', 'WashroomController@index');    //获取厕所列表
    Route::get('/{id}', 'WashroomController@show');      //获取厕所详情
});

//旅游路线
Route::group([
    'prefix' => 'travelline',
], function () {
    Route::get('/index/{order?}', 'TravellineController@index');    //获取旅游路线列表
    Route::get('/{id}', 'TravellineController@show');      //获取旅游路线详情并且更新浏览量
});

//配套设施
Route::group([
    'prefix' => 'matchset',
], function () {
    Route::get('/index/{order?}', 'MatchsetController@index');    //获取配套设施列表
    Route::get('/{id}', 'MatchsetController@show');      //获取配套设施详情
});

//交通
Route::group([
    'prefix' => 'traffic',
], function () {
    Route::get('/index', 'TrafficController@index');    //获取交通列表
    Route::get('/{id}', 'TrafficController@show');      //获取交通详情
    Route::get('/{id}/lines', 'TrafficController@getLines');      //获取交通下的路线列表

});

//酒店
Route::group([
    'prefix' => 'hotel',
], function () {
    Route::get('/index', 'HotelController@index');    //获取酒店列表
    Route::get('/{id}', 'HotelController@show');      //获取酒店详情
    Route::get('/{id}/room', 'HotelController@getRooms');      //获取酒店下的热推客房
});


//                                          旅游咨询

//旅游活动
Route::group([
    'prefix' => 'activity',
], function () {
    Route::get('/index/{order?}/{num?}', 'ActivityController@index');    //获取旅游活动列表
    Route::get('/{id}', 'ActivityController@show');      //获取旅游活动详情
});
//工作动态
Route::group([
    'prefix' => 'job',
], function () {
    Route::get('/index/{order?}/{num?}', 'JobController@index');    //获取工作动态列表
    Route::get('/{id}', 'JobController@show');      //获取工作动态详情
});
//政务公开
Route::group([
    'prefix' => 'government',
], function () {
    Route::get('/index/{type?}/{num?}', 'GovernmentController@index');    //获取政务公开列表
    Route::get('/{id}', 'GovernmentController@show');      //获取政务公开详情
});
//旅游公告
Route::group([
    'prefix' => 'notice',
], function () {
    Route::get('/index/{num?}', 'NoticeController@index');    //获取旅游公告列表
    Route::get('/{id}', 'NoticeController@show');      //获取旅游公告详情
});


//                                          游记
Route::group([
    'prefix' => 'travelnote',
], function () {
    Route::get('/index/{num?}', 'TravelnoteController@index');    //获取游记列表
    Route::get('/info', 'TravelnoteController@info');      //获取游记信息
    Route::get('/{id}', 'TravelnoteController@show');      //获取游记详情
    Route::get('/search/{input}', 'TravelnoteController@search');      //按区域搜索

    Route::post('/store', 'TravelnoteController@store');      //写游记
});

//                                          旅游画册
Route::group([
    'prefix' => 'album',
], function () {
    Route::get('/index/{num?}', 'AlbumController@index');    //获取旅游画册列表
    Route::get('/{id}', 'AlbumController@show');      //获取旅游画册详情
    Route::get('/search/{id}/{order?}/{num?}', 'AlbumController@search');      //按区域搜索
    Route::post('/store', 'AlbumController@store');      //提交画册
    Route::post('/zan', 'AlbumController@zan');      //画册点赞
});

//                                          实时监控
Route::group([
    'prefix' => 'monitor',
], function () {
    Route::get('/index/{order?}/{num?}', 'MonitorController@index');    //获取实时监控列表
    Route::get('/{id}', 'MonitorController@show');      //获取实时监控详情
});

//                                          主题直播
Route::group([
    'prefix' => 'live',
], function () {
    Route::get('/index/{order?}/{num?}', 'LiveController@index');    //获取主题直播列表
    Route::get('/{id}', 'LiveController@show');      //获取主题直播详情
});

//                                          720常德
Route::group([
    'prefix' => 'panorama',
], function () {
    Route::get('/index/{order?}/{num?}', 'PanoramaController@index');    //获取720常德列表
    Route::get('/{id}', 'PanoramaController@show');      //获取720常德详情
});

//                                          旅游歌曲
Route::group([
    'prefix' => 'song',
], function () {
    Route::get('/index/{num?}', 'SongController@index');    //获取旅游歌曲列表
});

//                                          精品路线
Route::group([
    'prefix' => 'selectedline',
], function () {
    Route::get('/index/{type?}/{num?}', 'SelectedlineController@index');    //获取精品路线列表
    Route::get('/menu', 'SelectedlineController@menu');      //获取精品路线菜单
    Route::get('/{id}', 'SelectedlineController@show');      //获取精品路线详情
});